package com.joe.other;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class T3 {


    public static void main(String[] args) {
        String a = "[{\"String\":\"https://chat-profile.oss-cn-hangzhou.aliyuncs.com/7011/portal/h5/banner/1.png\"}\n" +
                ",{\"String\":\"https://chat-profile.oss-cn-hangzhou.aliyuncs.com/7011/portal/h5/banner/2.jpg\"}\n" +
                " ,{\"String\":\"https://chat-profile.oss-cn-hangzhou.aliyuncs.com/7011/portal/h5/banner/3.jpg\"}\n" +
                "]";



        String target = "{\n" +
                "  \"navList\": [\n" +
                "    {\n" +
                "      \"id\": 0,\n" +
                "      \"isShow\": true,\n" +
                "      \"isNav\": true,\n" +
                "      \"name\": \"课程\",\n" +
                "      \"link\": \"/home\",\n" +
                "      \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/Uhome.png\"\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": 1,\n" +
                "      \"isShow\": true,\n" +
                "      \"isNav\": true,\n" +
                "      \"name\": \"题库\",\n" +
                "      \"link\": \"/tiku\",\n" +
                "      \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/Utiku-footer.png\"\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": 2,\n" +
                "      \"isShow\": true,\n" +
                "      \"isNav\": true,\n" +
                "      \"name\": \"学习中心\",\n" +
                "      \"link\": \"/learningCenter\",\n" +
                "      \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/UstudyCenter.png\"\n" +
                "    },\n" +
                "    {\n" +
                "      \"id\": 3,\n" +
                "      \"isShow\": true,\n" +
                "      \"isNav\": true,\n" +
                "      \"name\": \"我的\",\n" +
                "      \"link\": \"/person\",\n" +
                "      \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/Umy-footer.png\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"projectConfig\": \"TEMPLATE_1\",\n" +
                "  \"bannerList\": [\n" +
                "    {\n" +
                "      \"id\": 0,\n" +
                "      \"src\": \"//probe.bjmantis.net/7011/upload/h5Config/5b4f69f058d744baba46c83ecb2061ec.png\",\n" +
                "      \"link\": null\n" +
                "    }\n" +
                "  ],\n" +
                "  \"otherModuleConfig\": [\n" +
                "    {\n" +
                "      \"value\": \"category\",\n" +
                "      \"template\": \"TEMPLATE_2\",\n" +
                "      \"categoryNumber\": 4,\n" +
                "      \"navList\": [\n" +
                "        {\n" +
                "          \"id\": 0,\n" +
                "          \"isShow\": true,\n" +
                "          \"isNav\": true,\n" +
                "          \"name\": \"公开课\",\n" +
                "          \"link\": \"/public\",\n" +
                "          \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/openclass.png\"\n" +
                "        },\n" +
                "        {\n" +
                "          \"id\": 1,\n" +
                "          \"isShow\": true,\n" +
                "          \"isNav\": true,\n" +
                "          \"name\": \"系统班\",\n" +
                "          \"link\": \"/systemClassList\",\n" +
                "          \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/systemclass.png\"\n" +
                "        },\n" +
                "        {\n" +
                "          \"id\": 2,\n" +
                "          \"isShow\": true,\n" +
                "          \"isNav\": true,\n" +
                "          \"name\": \"免费课\",\n" +
                "          \"link\": \"/freeCourseList\",\n" +
                "          \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/freeclass.png\"\n" +
                "        },\n" +
                "        {\n" +
                "          \"id\": 3,\n" +
                "          \"isShow\": true,\n" +
                "          \"isNav\": true,\n" +
                "          \"name\": \"题库\",\n" +
                "          \"link\": \"/tiku\",\n" +
                "          \"iconUrl\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/tiku.png\"\n" +
                "        }\n" +
                "      ]\n" +
                "    },\n" +
                "    {\n" +
                "      \"value\": \"publicClass\",\n" +
                "      \"template\": \"TEMPLATE_1\",\n" +
                "      \"src\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/publicClass1.png\"\n" +
                "    },\n" +
                "    {\n" +
                "      \"value\": \"freeLessons\",\n" +
                "      \"template\": \"TEMPLATE_1\",\n" +
                "      \"src\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/freeLessons1.png\"\n" +
                "    },\n" +
                "    {\n" +
                "      \"value\": \"commodity\",\n" +
                "      \"template\": \"TEMPLATE_1\",\n" +
                "      \"src\": \"//probe.bjmantis.net/hc/hcMobile/onlineSchoolConfig/commodity1.png\"\n" +
                "    }\n" +
                "  ],\n" +
                "  \"version\": \"0\",\n" +
                "  \"serviceAgentId\": 275\n" +
                "}";
        H5ConfigDTO targetObj = JSON.parseObject(target, H5ConfigDTO.class);
        targetObj.setServiceAgentId(311);
        targetObj.setVersion(0);

        List<Banner> bannerList = targetObj.getBannerList();
        if (bannerList == null) {
            bannerList = new ArrayList<>();
        }
        bannerList.clear();

        List<Map<String, String>> oldBanner = JSON.parseObject(a, List.class);
        for (int i = 0; i < oldBanner.size(); i++) {
            Map<String, String> t = oldBanner.get(i);
            bannerList.add(new Banner(i, t.get("String")));
        }
        System.out.println(JSON.toJSONString(targetObj, SerializerFeature.WriteMapNullValue));

    }

    public static class H5ConfigDTO {
        private List<Nav> navList;

        private String projectConfig;

        private List<Banner> bannerList;

        private List<OtherModuleConfig> otherModuleConfig;

        private Integer version;

        private Integer serviceAgentId;

        public List<Nav> getNavList() {
            return this.navList;
        }

        public void setNavList(List<Nav> navList) {
            this.navList = navList;
        }

        public String getProjectConfig() {
            return this.projectConfig;
        }

        public void setProjectConfig(String projectConfig) {
            this.projectConfig = projectConfig;
        }

        public List<Banner> getBannerList() {
            return this.bannerList;
        }

        public void setBannerList(List<Banner> bannerList) {
            this.bannerList = bannerList;
        }

        public List<OtherModuleConfig> getOtherModuleConfig() {
            return this.otherModuleConfig;
        }

        public void setOtherModuleConfig(List<OtherModuleConfig> otherModuleConfig) {
            this.otherModuleConfig = otherModuleConfig;
        }

        public Integer getVersion() {
            return this.version;
        }

        public void setVersion(Integer version) {
            this.version = version;
        }

        public Integer getServiceAgentId() {
            return this.serviceAgentId;
        }

        public void setServiceAgentId(Integer serviceAgentId) {
            this.serviceAgentId = serviceAgentId;
        }
    }

    public static class Nav {
        private Integer id;
        private Boolean isShow;
        private Boolean isNav;
        private String name;
        private String link;
        private String iconUrl;

        public Integer getId() {
            return this.id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public Boolean getIsShow() {
            return this.isShow;
        }

        public void setIsShow(Boolean isShow) {
            this.isShow = isShow;
        }

        public Boolean getIsNav() {
            return this.isNav;
        }

        public void setIsNav(Boolean isNav) {
            this.isNav = isNav;
        }

        public String getName() {
            return this.name;
        }

        public void setName(String name) {
            this.name = name;
        }

        public String getLink() {
            return this.link;
        }

        public void setLink(String link) {
            this.link = link;
        }

        public String getIconUrl() {
            return this.iconUrl;
        }

        public void setIconUrl(String iconUrl) {
            this.iconUrl = iconUrl;
        }
    }

    public static class Banner {

        private Integer id;
        private String src;
        private String link;

        public Banner() {
        }

        public Banner(Integer id, String src) {
            this.id = id;
            this.src = src;
        }

        public Integer getId() {
            return this.id;
        }

        public void setId(Integer id) {
            this.id = id;
        }

        public String getSrc() {
            return this.src;
        }

        public void setSrc(String src) {
            this.src = src;
        }

        public String getLink() {
            return this.link;
        }

        public void setLink(String link) {
            this.link = link;
        }
    }


    public static class OtherModuleConfig {
        private String value;
        private String template;
        private Integer categoryNumber;
        private List<Nav> navList;

        public String getValue() {
            return this.value;
        }

        public void setValue(String value) {
            this.value = value;
        }

        public String getTemplate() {
            return this.template;
        }

        public void setTemplate(String template) {
            this.template = template;
        }

        public List<Nav> getNavList() {
            return this.navList;
        }

        public void setNavList(List<Nav> navList) {
            this.navList = navList;
        }

        public Integer getCategoryNumber() {
            return this.categoryNumber;
        }

        public void setCategoryNumber(Integer categoryNumber) {
            this.categoryNumber = categoryNumber;
        }
    }
}
